from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
from app.models.user import UserRole

class UserBase(BaseModel):
    phone: str = Field(..., max_length=20)
    role: UserRole = UserRole.CUSTOMER

class UserCreate(UserBase):
    wechat_openid: Optional[str] = None
    username: Optional[str] = None
    password: Optional[str] = None

class UserUpdate(BaseModel):
    phone: Optional[str] = None

class UserResponse(UserBase):
    id: int
    wechat_openid: Optional[str] = None
    username: Optional[str] = None
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

